import bus from '@/bus'
let data = {
  status: 'pass',
  totalItem: 1,
  pageSize: window.$pageSize,
  currentPage: 1,
  columns: [{
    align: 'left',
    key: 'storeServerId',
    minWidth: 150,
    fixed: 'left',
    renderHeader: (h, param) => {
      return h('div', [
        h('span', {
          class: 'font-red'
        }, '*'),
        h('span', '服务项目')
      ])
    },
    render: (h, params) => {
      let row = params.row
      let optionArr = []
      row.allType.forEach(item => {
        optionArr.push(h('Option', {
          props: {
            value: item.categoryId
          }
        }, item.name))
      })
      return h('Select', {
          props:{
            value: row.storeServerId
          },
          on: {
            'on-change':(e) => {
              row.storeServerId = e
              bus.$emit('onChangeNum', { row: params.row, index: params.index })
            }
          },
      }, optionArr)
    }
  }, {
    title: '起步公里数(km)',
    key: 'startNumber',
    align: 'left',
    minWidth: 150,
    fixed: 'left',
    render: (h, params) => {
      return h('div', [
        h('InputNumber', {
          props: {
            value: params.row.startNumber,
            min: 0
          },
          on: {
            'on-change': e => {
              params.row.startNumber = e
              bus.$emit('onChangeNum', { row: params.row, index: params.index })
            }
          }
        })
      ])
    }
  }, {
    key: 'startTime',
    align: 'left',
    minWidth: 150,
    fixed: 'left',
    renderHeader: (h, param) => {
      return h('div', [
        h('span', {
          class: 'font-red'
        }, '*'),
        h('span', '起步时间(分钟)')
      ])
    },
    render: (h, params) => {
      return h('div', [
        h('InputNumber', {
          props: {
            value: params.row.startTime,
            min: 0
          },
          on: {
            'on-change': e => {
              params.row.startTime = e
              bus.$emit('onChangeNum', { row: params.row, index: params.index })
            }
          }
        })
      ])
    }
  }, {
    title: '起步价(元)',
    key: 'startFee',
    align: 'left',
    minWidth: 150,
    fixed: 'left',
    render: (h, params) => {
      return h('div', [
        h('InputNumber', {
          props: {
            value: params.row.startFee,
            min: 0
          },
          on: {
            'on-change': e => {
              params.row.startFee = e
              bus.$emit('onChangeNum', { row: params.row, index: params.index })
            }
          }
        })
      ])
    }
  }, {
    title: '公里单价(元)',
    key: 'perKilometreFee',
    align: 'left',
    minWidth: 150,
    render: (h, params) => {
      return h('div', [
        h('InputNumber', {
          props: {
            value: params.row.perKilometreFee,
            min: 0
          },
          on: {
            'on-change': e => {
              params.row.perKilometreFee = e
              bus.$emit('onChangeNum', { row: params.row, index: params.index })
            }
          }
        })
      ])
    }
  }, {
    title: '夜间服务开始时间',
    key: 'darkStartTime',
    align: 'left',
    width: 250,
    render: (h, params) => {
      return h('div', [
        h('TimePicker', {
          props: {
            format: 'HH:mm',
            placeholder: '选择夜间服务开始时间',
            transfer: true,
            value: params.row.darkStartTime
          },
          on: {
            'on-change': e => {
              if (e) {
                params.row.darkStartTime = e
              } else {
                params.row.darkStartTime = ''   // 必须有各种判断，否则清空时无法解除之前的禁用
              }
            }
          }
        })
      ])
    }
  }, {
    title: '夜间服务结束时间',
    key: 'darkEndTime',
    align: 'left',
    width: 250,
    render: (h, params) => {
      return h('div', [
        h('TimePicker', {
          props: {
            format: 'HH:mm',
            placeholder: '选择夜间服务开始时间',
            transfer: true,
            value: params.row.darkEndTime
          },
          on: {
            'on-change': e => {
              if (e) {
                params.row.darkEndTime = e
              } else {
                params.row.darkEndTime = ''   // 必须有各种判断，否则清空时无法解除之前的禁用
              }
            }
          }
        })
      ])
    }
  }, {
    key: 'payType',
    align: 'left',
    minWidth: 120,
    renderHeader: (h, param) => {
      return h('div', [
        h('span', {
          class: 'font-red'
        }, '*'),
        h('span', '收费方式')
      ])
    },
    render: (h, params) => {
      let row = params.row
      return h('Select', {
        props:{
          value: row.payType,
        },
        on: {
          'on-change':(e) => {
            row.payType = e
            bus.$emit('onChangeNum', { row: params.row, index: params.index })
          }
        },
      },
      [
        h('Option',{
          props: {
            value: 'MINUTE'
          }
        }, '按分钟收费'),
        h('Option',{
          props: {
            value: 'NUMBER'
          }
        }, '按次数收费')
      ])
    }
  }, {
    title: '夜间服务费',
    key: 'darkServerFee',
    align: 'left',
    minWidth: 200,
    render: (h, params) => {
      let x
      switch (params.row.payType)
      {
      case 'MINUTE':
        x = '元/分钟'
        break
      case 'NUMBER':
        x = '元/次数'
        break
      }
      return h('div', [
        h('InputNumber', {
          props: {
            value: params.row.darkServerFee,
            min: '0'
          },
          on: {
            'on-change': e => {
              params.row.darkServerFee = e
              bus.$emit('onChangeNum', { row: params.row, index: params.index })
            }
          }
        }),
        h('span', x)
      ])
    }
  }, {
    title: '非夜间服务费',
    key: 'serverFee',
    align: 'left',
    minWidth: 150,
    render: (h, params) => {
      let x
      switch (params.row.payType)
      {
      case 'MINUTE':
        x = '元/分钟'
        break
      case 'NUMBER':
        x = '元/次数'
        break
      }
      return h('div', [
        h('InputNumber', {
          props: {
            value: params.row.serverFee,
            min: 0
          },
          on: {
            'on-change': e => {
              params.row.serverFee = e
              bus.$emit('onChangeNum', { row: params.row, index: params.index })
            }
          }
        }),
        h('span', x)
      ])
    }
  }, {
    title: '长途阀值(km)',
    key: 'longDistance',
    align: 'left',
    minWidth: 150,
    render: (h, params) => {
      return h('div', [
        h('InputNumber', {
          props: {
            value: params.row.longDistance,
            min: 0
          },
          on: {
            'on-change': e => {
              params.row.longDistance = e
              bus.$emit('onChangeNum', { row: params.row, index: params.index })
            }
          }
        })
      ])
    }
  }, {
    title: '长途溢价(元/km)',
    key: 'longDistanceFee',
    align: 'left',
    minWidth: 150,
    render: (h, params) => {
      return h('div', [
        h('InputNumber', {
          props: {
            value: params.row.longDistanceFee,
            min: 0
          },
          on: {
            'on-change': e => {
              params.row.longDistanceFee = e
              bus.$emit('onChangeNum', { row: params.row, index: params.index })
            }
          }
        })
      ])
    }
  }, {
    title: '操作',
    align: 'left',
    minWidth: 150,
    fixed: 'right',
    render: (h, params) => {
      return h('div', [
        h('Button', {
          props: {
            size: 'small'
          },
          on: {
            click: () => {
              bus.$emit('onDelete', { id: params.row.id, index: params.index })
            }
          }
        }, '删除')
      ])
    }
  }],
  data: []
}
export default data